home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1993 January / 1993-01.d64 / total sort (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  16KB  |  545 lines

  1. 5 rem modified 12/27/91
  2. 7 rem for printers with auto paging delete lines 2720-2740 and remove pokes
  3. 8 rem from lines 2810 & 2850
  4. 10 rem this version requires mlswap.obj
  5. 20 rem & screen.obj to be loaded 1st
  6. 30 poke53281,0:poke53280,11
  7. 40 print"[147]totalizer"
  8. 50 print"by"
  9. 60 print"randy clemmons"
  10. 70 rem initialize variables
  11. 80 dim nc,ad,da,fs,sn,yn$,ju$,mu$,er,f$,sb,fl$,en,em$,et,es,ta,av,at,rs:dc=1
  12. 90 dim i,sf,ss$,cl,vf,hn,x,tr,df,x$,sl,w,c$,l,sp$,ca$,in,tn,ts,te,tx,af,j,dt$
  13. 100 dim lg,lk,cr$,hd$,hd,pa,j$,le,lt,ps,sh,ns,k,di,db,dq,n,tp,ub,lb,te$,tb$,nd%
  14. 105 dim mc,lm$:dv=4
  15. 110 dim cb,ck,p1,p2,ve,ao,yn,vf$,ve$,ta$,i$,tm,rm$,sc:dc=1:nc=1:lm=15:rm=60
  16. 120 print"copyright 1993"
  17. 130 gosub3440:dimd$(503):dima$(503):fs=1:sn=1:d$(0)="":a$(0)="":goto1270
  18. 140 err=0:if d$(1)="" then gosub3370:return
  19. 150 print"[158][147]  save and replace file"
  20. 155 print"  return to menu  return [146]"
  21. 160 print"  file directory  ^ or $ [146]"
  22. 170 print""spc(28)"save":f$=""
  23. 180 printspc(27)"[207][183][183][183][183][208]
  24. 190 [153][166]27)"sgn (NULL)right$ +
  25. 200 printspc(27)"[180] [202][203] [170]
  26. 210 [153][166]27)"sgn then  +
  27. 220 printspc(27)"[183][183][183][183][183][183]":ifsb=1thensb=0:return
  28. 230 input"  save file name";f$
  29. 240 if f$="" then return
  30. 250 iff$="^" then poke52233,6:gosub3260:goto150
  31. 255 iff$="$" then poke52233,1:gosub3260:goto150
  32. 260 print"saving ";f$
  33. 270 open15,8,15,"i0":gosub610
  34. 280 open2,8,2,"@0:"+f$+",s,w":gosub610: cr$=chr$(13):if err=1 then140
  35. 290 print#2,str$(nc)cr$;str$(ta)cr$;str$(sn)cr$;str$(dc)cr$;str$(av)cr$;str$(at)
  36. 300 for i=1 to 500 step 3
  37. 310 print#2,d$(i)","a$(i)cr$;d$(i+1)","a$(i+1)cr$;d$(i+2)","a$(i+2)cr$;
  38. 320 if d$(i+2)="" then i=512
  39. 330 next i:gosub610
  40. 340 close 2:close15:sf=1:fs=1
  41. 350 return
  42. 360 if d$(1)="" goto390
  43. 370 if fs=1 then goto390
  44. 380 print"[147]":gosub3300:if yn$="y" then return
  45. 390 err=0:print"[159][147]  return to menu  return [146]"
  46. 400 print"  file directory  ^ or $ [146]"
  47. 410 print""spc(28)"load":f$=""
  48. 420 sb=1:gosub180
  49. 430 input"  load file name";f$
  50. 435 if f$="" then return
  51. 440 iff$="^" then poke52233,6:gosub3260:goto390
  52. 445 iff$="$" then poke52233,1:gosub3260:goto390
  53. 460 fl$="0:"+f$+","+"s,r"
  54. 470 print"reading ";f$
  55. 480 open15,8,15,"i0":gosub610:open2,8,2,fl$:gosub610
  56. 485 iferr=1then close2:close15:goto390
  57. 490 input#2,nc,ta,sn,dc,av,at:rs=st:gosub610
  58. 500 for i=1 to 500 step 4 :rem gosub7000
  59. 510 input#2,d$(i),a$(i),d$(i+1),a$(i+1),d$(i+2),a$(i+2),d$(i+3),a$(i+3)
  60. 520 rs=st:gosub610:ifd$(i)=""then i=512
  61. 530 if rs=64 then560
  62. 540 if rs<>0 then590
  63. 550 next i
  64. 560 close 2:close15
  65. 570 sf=1:fs=1
  66. 580 return
  67. 590 print"bad disk status is "rs
  68. 600 close 2
  69. 610 en=0:input#15,en,em$,et,es
  70. 620 if en=0 then return
  71. 630 print"error on disk"
  72. 640 printen;em$;et;es
  73. 650 close 2:close15
  74. 660 fort=1to900:nextt:err=1:return
  75. 670 print "[147]create new file"
  76. 680 if d$(1)="" then 701
  77. 690 if fs=1 then 701
  78. 700 gosub3300:if yn$="y" then return
  79. 701 print"[155] options ? [161]y/n[182][146]"
  80. 702 gosub3330:if yn$="y" then 710
  81. 705 print"[147]":goto 800
  82. 710 x=0:print"[147]"spc(15)"[159]options":if mu$="n" then at=0
  83. 715 print"[155]enter amounts only       ";
  84. 716 yn=ao:gosub4840:ao=yn
  85. 720 print"[155]commas in descriptions   ";
  86. 730 yn=nc:gosub4920:nc=yn
  87. 740 print"compute taxes for total  ";
  88. 745 ifta>1thenta=1
  89. 750 yn=ta:gosub4840:ta=yn
  90. 754 ifyn=0then 760
  91. 755 dc=1:print"percentage   ";ta$
  92. 756 input"[145]";ta$:ta=val(ta$):goto780
  93. 760 print"use integers with amounts";
  94. 770 yn=dc:gosub4920:dc=yn
  95. 780 print"compute average amount   ";
  96. 790 yn=av:gosub4840:av=yn
  97. 800 print"[155]":fs=0:ifca$="o"then return
  98. 805 print"[147]"
  99. 810 at=0:for i=1 to 500:d$(i)="":a$(i)="":print"item no. ";i
  100. 815 if ao=1 then d$(i)="":goto 860
  101. 820 rem if nc=0 then poke631,34:poke198,1
  102. 830 cl=peek(214):input"description";d$(i)
  103. 840 lk=peek(214):if lk-cl>2 then gosub3390:goto820
  104. 850 if d$(i)="" then sn=i:i=512:goto880
  105. 860 gosub3410:x=0:x$=""
  106. 861 input"amount";x$:x=val(x$)
  107. 863 ifdc=0thenat=at+int(x):goto867
  108. 865 at=at+x
  109. 867 if ao=1 then if x$="" then sn=i:d$(i)="":i=512:goto880
  110. 868 gosub3640:a$(i)=x$
  111. 870 x=at:gosub3640:print"total=";x$;"[182]
  112. 880 [130] i
  113. 890 [153] "finished":fs[178]0
  114. 900 [137]1130
  115. 910  [143] swap out commas w/semi colons
  116. 920 [139] d$(1)[178]""[167] [142]
  117. 940 [151]50949,44:[151]50950,59:[158]50951:sf[178]1:[142]
  118. 950  [143] swap out semi colons w/commas
  119. 960  [151]50949,59:[151]50950,44:[158]50951:sf[178]0:[142]
  120. 970 ss$[178]"      ":cl[178]0:d$(501)[178]""
  121. 980 [139] d$(1)[178]"" [167] [141]3370:[142]
  122. 990 vf[178]1:hn[178]sn[171]1:[153]"loadlast no. is ";hn
  123. 1000 [153]"start viewing from item no.   1"
  124. 1010 [139] nc[178]1 [167]1030
  125. 1015 [141]950
  126. 1020 [139] sf[178]1 [167] [141]950
  127. 1030 [133]"on";vf$:vf[178][197](vf$)
  128. 1031 [139] vf[179]1 [167] 1030
  129. 1032 [139] vf[177]hn [167] 1030
  130. 1040 [139][194](214)[177]8[167]pk[178]1024[170]([194](214)[172]40)[171]7:[129]i[178]0[164]2:[151]1337[170]i,[194](pk[170]i):[130]i
  131. 1050 [139][194](1337)[178]32[167][151]1337,49
  132. 1060 [139] vf[177]hn [167] [153]"loadhighest no. is ";hn:[129]t[178]1[164]600:[130]t:[137]1000
  133. 1070 [151]51153,0:[139] vf[177]255 [167] [151]51153,1:[151]51153,vf[171]256:[137]1090
  134. 1080 [151]51152,vf
  135. 1090 [151]51154,0:[143] reset return flag
  136. 1100 [158]51200:[143] ml screen routine
  137. 1110 [139] [194](51154)[178]1 [167] [142]
  138. 1120 [139] [194](51154)[178]0 [167] x[178]at:[141]1200
  139. 1130 [153]"           <any key to return>":[141]3620
  140. 1140 [161] sp$:[139] sp$[178]"" [167]1140
  141. 1150 [142]
  142. 1160 [141]3640
  143. 1170 [139] ca$[178]"v"[167]1190
  144. 1180 [139] mu$[179][177]"v"[167] [142]
  145. 1190 [153] [166]39[171]l);"on";x$:[142]
  146. 1200 [139] ta[178]0 [167]1230
  147. 1210 tx[178]x:[141]1260:[153]"      subtotal":[141]1160:[141]1260:[153]"      taxes";
  148. 1220 [153]" ";ta;"cmd%":x[178]x[172](ta[172].01):[141]1160:x[178]tx[170]x
  149. 1230 [141]1260:[153]"      total":[141]1160
  150. 1240 [139] av[178]1 [167] [141]1260:[153]"      average":x[178]x[173](sn[171]1):af[178]1:[141]1160
  151. 1250 [142]
  152. 1260 [153] [166]29);"----------":[142]
  153. 1270 [153]"load                 menu":yn$[178]""
  154. 1280 [153]"list            tototo totototototototo "
  155. 1290 [153]"             n.wait new filewait"
  156. 1300 [153]"sys            tototo tototototototototo "
  157. 1310 [153]"             s.wait save filewait"
  158. 1320 [153]"open            tototo tototototototototo "
  159. 1330 [153]"             l.wait load filewait"
  160. 1340 [153]"list            tototo tototototototototo "
  161. 1350 [153]"             v.wait view filewait"
  162. 1360 [153]"print            tototo tototototototototo "
  163. 1370 [153]"             e.wait edit filewait"
  164. 1380 [153]"cont            tototo totototototototototo "
  165. 1390 [153]"             p.wait print filewait"
  166. 1400 [153]"list            tototo tototototototototototototo "
  167. 1410 [153]"             x.wait exit to basicwait":[141]3620
  168. 1420 [161] mu$:[139] mu$[178]"" [167]1420
  169. 1430 [139] mu$[178]"n" [167] [141]670:[137]1270
  170. 1440 [139] mu$[178]"s" [167] [141]4000:[141]920:[141]140:[137]1270
  171. 1450 [139] mu$[178]"l" [167] [141]4000:[141]360:[137]1270
  172. 1460 [139] mu$[178]"v" [167] [141]970:[137]1270
  173. 1470 [139] mu$[178]"e" [167] [141]1550:[137]1270
  174. 1480 [139] mu$[178]"p" [167] [141]2610:[137]1270
  175. 1490 [139] mu$[178]"x" [167]1510
  176. 1500 [137]1420
  177. 1510 [139] d$(1)[178]"" [167] [153]"load":[128]
  178. 1520 [139] fs[178]1 [167] [153]"load":[128]
  179. 1530 [153]"load":[141]3300:[139] yn$[178]"y" [167]1270
  180. 1540 [139] yn$[178]"n"[167] [153]"loadlist":[128]
  181. 1550 [139] d$(1)[178]"" [167] [141]3370:[142]
  182. 1560 [153] "printload             file editor"
  183. 1565 [139] nc[178]0 [167] [141]950
  184. 1567 [139] nc[178]1 [167] [141]910
  185. 1570 [153] [166]14)"to
  186. 1580 print spc(14)"a[146]dd to
  187. 1590 [153] [166]14)"to
  188. 1600 print spc(14)"c[146]hange
  189. 1610 [153] [166]14)"to
  190. 1620 print spc(14)"d[146]elete
  191. 1630 [153] [166]14)"to
  192. 1640 print spc(14)"i[146]nsert
  193. 1650 [153] [166]14)"to
  194. 1660 print spc(14)"m[146]ove
  195. 1670 [153] [166]14)"to
  196. 1680 print spc(14)"o[146]ptions
  197. 1690 [153] [166]14)"to
  198. 1700 print spc(14)"s[146]ort
  199. 1710 [153] [166]14)"to
  200. 1720 print spc(14)"r[146]eturn
  201. 1730 [153] [166]14)"to
  202. 1740 print spc(14)"v[146]iew
  203. 1750 [153] [